<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        function setTime(){
            var date = new Date();
            var week = date.getDay();
            var str = date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日\t"+"\t星期"+week+"\t"
                +date.getHours()+"时"+date.getMinutes()+"分"+date.getSeconds()+"秒";

            document.getElementById("d1").innerHTML="当前时间为："+str;
        }

        function winTime(){
            setTime();
            window.setInterval('setTime()',1000);
        }
    </script>
</head>
<body onload="winTime()">
<div id="d1">

</div>
</body>
</html>